<?php
//自定义边栏模版数据读取
namespace Admin\Widget;
use Think\Controller;
class SidebarWidget extends Controller {
	
	//边栏列表
    public function Sidebar_list(){
		
		$fl				= D('Fungro','Logic');
		$Role			= D('Role','Logic');

		//获取角色权限
		$role_id		= session('role_id');
		$user_id		= session('id');
		$cache_name		= 'sidebar_'.$user_id.'_'.$role_id;
		
		if(!S($cache_name)){

			$oper_auth 		= $Role->getFieldById($role_id,'oper_auth');
			
			if($oper_auth){
				$oa_list	= explode(',',$oper_auth);
				$list 		= $fl->getGroupByArray($oa_list);
			}
			foreach($list as $k => $v){
				$FGlist[$k]		= $fl->find($k);
				for($i=0;$i<count($v);$i++){
					$FGlist[$k]['subFG'][$i]	= $fl->find($v[$i]);
				}
			}
			S($cache_name,$FGlist,3600);
		}
		else{
			$FGlist		= S($cache_name);
		}
		$this->assign('FGlist',$FGlist);
		$this->display('Public:sidebar_list');
    }
	
}